package com.thinkgem.jeesite.modules.common;

/**
 * Created by green on 2018/5/1.
 */
public class JSONResult {
    public static final String CODE_SUCCESS = "1";
    public static final String CODE_FAIL = "0";

    private String code;
    private String message;
    private Object data;

    public JSONResult(){}
    public JSONResult(String code){
        this(code, null);
    }

    public JSONResult(String code, String message){
        this(code, message, null);
    }

    public JSONResult(String code, String message, Object data){
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public boolean isSuccess(){
        return CODE_SUCCESS.equals(code);
    }

    public static JSONResult SUCCESS(){
        return SUCCESS(null);
    }
    public static JSONResult SUCCESS(String message){
        return SUCCESS(message, null);
    }
    public static JSONResult SUCCESS(String message, Object data){
        return new JSONResult(CODE_SUCCESS, message, data);
    }
    public static JSONResult FAIL(){
        return FAIL(null);
    }
    public static JSONResult FAIL(String message){
        return FAIL(message, null);
    }
    public static JSONResult FAIL(String message, Object data){
        return new JSONResult(CODE_FAIL, message, data);
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
